#ifndef MYDRAWINGAREA_H_INCLUDED
#define MYDRAWINGAREA_H_INCLUDED

#include <gtkmm/main.h>
#include <gtkmm.h>
#include <iostream>
#include <vector>

#include "Misc.h"
#include "Debug.h"


#define MIN_SEL_REC_LENGTH 20
#define SEL_REC_ARC_RAD 5
#define SEL_REC_INIT_X 10
#define SEL_REC_INIT_Y 10


class MyDrawingArea : public Gtk::DrawingArea
{
    public:
        MyDrawingArea();
        virtual ~MyDrawingArea();

    protected:
        int   	m_src_x;
		int  	m_src_y;
		int  	m_width;
		int  	m_height;
        Glib::RefPtr<Gdk::Pixbuf> m_image;
        Cairo::RefPtr<Cairo::Context> cr;
        virtual bool on_expose_event(GdkEventExpose* event);

        class SelectionRect
        {
            public:
            gdouble m_x1;
            gdouble m_y1;
            gdouble m_x2;
            gdouble m_y2;

            uint m_sideThickness;
            bool m_visible;
            bool m_mouseDown;
            gdouble m_mouseLastX;
            gdouble m_mouseLastY;
            uint capturedSide;
        };

    public:
        SelectionRect m_srect;
        void setImage(Glib::RefPtr<Gdk::Pixbuf> &image, int src_x, int src_y, int width, int height);
        virtual bool on_motion_notify_event (GdkEventMotion* event);
        virtual bool on_button_press_event(GdkEventButton* event);
        virtual bool on_button_release_event(GdkEventButton* event);
        bool repaint(void);
        void drawSelrect();
        void selrectTrack(GdkEventButton* event);
};


#endif // MYDRAWINGAREA_H_INCLUDED
